﻿using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Security.Principal;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Security;
using NETMovie.UI.WebMVC.Models;
using NETMovie.BLL;
using NETMovie.UI.WebMVC.Mappers;
using NETMovie.Entities;

namespace NETMovie.UI.WebMVC.Controllers
{
    public class MoiveController : Controller
    {
        //
        // GET: /Moive/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult View()
        {
            return View();
        }

        public ActionResult Details()
        {
            return View();
        }

  

        //////[HttpPost]
        //////public ActionResult Search(SearchModel s, string SearchButton)
        //////{
        //////    NETMovieEntitiesContainer modelContext = new NETMovieEntitiesContainer();

        //////    s.Result = from f in modelContext.Flights
        //////               where f.Route.Departure.CityName == s.From
        //////                    && f.Route.Destination.CityName == s.To
        //////               select f;

        //////    if (Request.IsAjaxRequest())
        //////    {
        //////        return View("SearchResult", s.Result);
        //////    }
        //////    else
        //////    {
        //////        return View(s);
        //////    }
        //////}

        public ActionResult Search()
        {
           // AerolionMVCEntities modelContext = new AerolionMVCEntities();
            MovieModel  s = new MovieModel();
            Session["Category"] = GetCategory();
            Session["CastMember"] = GetCastMember();

            return View(s);
        }

        [HttpPost]
        public ActionResult Search(MovieModel s, string SearchButton)
        {
            var model = new MovieViewModel()
            {
                Category  = "Drama",
                Categories = GetCategory()

            
            };

            return View("SearchResult",model);

        }

        
        private IEnumerable<SelectListItem> GetCategory()
        {
            return new[] {
                new SelectListItem { Text = "Comedy", Value = "comedy" },
                new SelectListItem { Text = "Drama", Value = "drama" }
            };
        }

        private IEnumerable<SelectListItem> GetCastMember()
        {
            return new[] {
                new SelectListItem { Text = "Tom", Value = "tom" },
                new SelectListItem { Text = "Jolie", Value = "jolie" }
            };
        }
    }
}
